var familias = {
		init:function(){
			var familia = this;
			$('#familias').jqGrid({
	           url:'familias/index',
	           datatype:'json',
	           mtype:'POST',
	           colNames:['id','codigo','Descripcion','Creado','Estado'],
	           colModel:[
	               {name:"data[Familia][id]",hidden:true},
	               {name:"data[Familia][codigo]",index:'Familia.codigo',width:40,align:"right",sortable:true,editable:true,editoptions:{size:8, maxlength:5},editrules:{required:true,number:true},searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
				   {name:"data[Familia][descripcion]",index:'Familia.descripcion',sortable:true,editable:true,editoptions:{size:25, maxlength:20},editrules:{required:true},searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Familia][created]",index:'Familia.created',width:50,sortable:true,editable:false,searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Familia][estado_id]",
				   		index:'Estado.descripcion',
						width:50,
						align:'left',
						editable: true,
						edittype:"select",
						editrules:{required:true},
						editoptions:{
							value:"1:Activo;2:Desactivo"
						},
						searchoptions:{
							sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']
						}
					}               
	           ],
			 
			   pager:$('#familias-pager'),
	           rowNum:10,
	           rowList:[10,20,30],
	           mtype: "POST",
	           viewrecords:true,
	           caption:'Familias',
	           height:'180',
	           sortname: "Familia.descripcion",
	           editurl: 'familias/index'
	          
	                
	       });
	       $('#familias').navGrid("#familias-pager",{edit:true,add:true,del:true},
		   {clearAfterEdit:false,reloadAfterSubmit:true, closeOnEscape:true,afterSubmit:familia.afterSubmit},
		   {clearAfterAdd:true,reloadAfterSubmit:true, closeOnEscape:true,afterSubmit:familia.afterSubmit},
		   {reloadAfterSubmit:true, closeOnEscape:true},{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew'],multipleSearch:true, closeOnEscape:true});
	       $("#familias").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
	       jQuery("#familias").jqGrid('setGridWidth',$('#RightPane').width()-50);
		},
		afterSubmit: function(response){var respuesta = JSON.parse(response.responseText); return [respuesta.respuesta,respuesta.mensaje];}
};